/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aimozg.utils;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author aimozg
 */
public class ListenerList<S,A> {
    
    private List<Listener<S,A>> list = new LinkedList<Listener<S,A>>();
    public void add(Listener<S,A> l){
        list.add(l);
    }
    public void remove(Listener<S,A> l){
        list.remove(l);
    }
    public List<Listener<S,A>> getList(){
        return list;
    }
    public void fire(S sender,A arg){
        for (Listener<S, A> listener : list) {
            listener.event(sender, arg);
        }
    }
    public void clear(){
        list.clear();
    }
    public ListenerPublicator<S,A> publicator(){
        return new ListenerPublicator<S, A>(this);
    }
}
